package MAP_study;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
//程序作用，将输入的学生及地址值打印输出来，用Map储存
public class Map_homewokr {
    public static void main(String[] args) {
        Map<Student,String> student = new HashMap<>();
        Student student1 = new Student("王一",19);
        Student student2 = new Student("李二",18);
        Student student3 = new Student("刘三",19);
        student.put(student1,"北京");
        student.put(student2,"北京");
        student.put(student3,"北京");
        student.put(new Student("王一",19),"上海");
        Set<Map.Entry<Student,String>> set = student.entrySet();
        Iterator<Map.Entry<Student,String>> it = set.iterator();
        while(it.hasNext())
        {
            Map.Entry<Student,String> entry = it.next();
            System.out.println("key:"+entry.getKey()+"value"+entry.getValue());
        }



    }
}
